package com.ruoyi.framework.interceptor;


import com.ruoyi.common.annotation.DemoSite;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.exception.ServiceException;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 演示站点拦截
 * DemoInterceptor
 *
 * @author siashan
 * @date 2023/3/31
 */
@Component
@Aspect
public class DemoInterceptor {

    @Autowired
    private RuoYiConfig ruoYiConfig;

    @Before("@annotation(demoSite)")
    public void doAfter(DemoSite demoSite) {
        if (Boolean.TRUE.equals(ruoYiConfig.isDemoEnabled())) {
            throw new ServiceException("演示站点禁止使用");
        }
    }

}
